<!DOCTYPE html>
<body>
  <script>
    async function requestLocation() {
      let promise = new Promise(r => {
        navigator.geolocation.getCurrentPosition(() => r(true), () => r(false));
      })
      let result = await promise;
      domAutomationController.send(result);
    };

    async function queryGeolocationPermission() {
      let status = await navigator.permissions.query({name: 'geolocation'});
      domAutomationController.send(status.state);
    }

    let adoptionPromise = new Promise(r => {
      window.onportalactivate = e => {
        let portal = e.adoptPredecessor();
        document.body.appendChild(portal);
        r();
      };
    });

    async function waitForAdoption() {
      await adoptionPromise;
      domAutomationController.send(true);
    }

  </script>
</body>
